package csu.web.mypetstore.web.servlet;

import csu.web.mypetstore.domain.Account;
import csu.web.mypetstore.domain.Product;
import csu.web.mypetstore.service.AccountService;
import csu.web.mypetstore.service.CatalogService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class NewAccountFormServlet extends HttpServlet {
    private static  final  String NEW_Account_FORM = "/WEB-INF/jsp/account/newAccount.jsp";

    private List<String> langList = new ArrayList<>();
    private List<String> catList = new ArrayList<>();

    private  void createList(){
        langList.clear();
        catList.clear();

        langList.add("english");
        langList.add("japanese");
        langList.add("chinese");

        catList.add("FISH");
        catList.add("DOGS");
        catList.add("REPTILES");
        catList.add("CATS");
        catList.add("BIRDS");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        createList();
        session.setAttribute("languages",langList);
        session.setAttribute("categories",catList);
        req.getRequestDispatcher(NEW_Account_FORM).forward(req,resp);
    }
}
